package com.quick.controller;

import com.quick.base.Page;
import com.quick.base.Search;
import com.quick.service.ISysDeptService;
import com.quick.sys.domain.dto.SysDeptDTO;
import com.quick.sys.domain.search.SysDeptSearch;
import com.quick.sys.domain.vo.SysDeptVo;
import com.quick.sys.domain.vo.SysPostVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/sys/dept")
@Api(tags ="部门管理")
@AllArgsConstructor
public class SysDeptController {

    private final ISysDeptService sysDeptService;
    @ApiOperation(value = "部门分页查询列表", notes = "部门分页查询列表")
    @PostMapping("search")
    public Page<SysDeptVo> search(@RequestBody Search<SysDeptSearch> search){
        return sysDeptService.search(search);
    }
    
    @ApiOperation(value = "新增部门", notes = "新增部门")
	@PostMapping("add")
	public Boolean addDept(@RequestBody SysDeptDTO role) {
		return sysDeptService.saveSysDept(role);
	}

	@ApiOperation(value = "查询部门", notes = "查询部门")
	@GetMapping("query/{id}")
	public SysPostVo query(@PathVariable("id") Long id) {
		return sysDeptService.queryById(id);
	}

	@ApiOperation(value = "删除部门", notes = "删除部门")
	@GetMapping("del/{id}")
	public Boolean del(@PathVariable("id") Long id) {
		return sysDeptService.delById(id);
	}

	@ApiOperation(value = "批量删除部门", notes = "批量删除部门")
	@PostMapping("batchDel")
	public Boolean batchDel(@PathVariable("id") List<Long> ids) {
		return sysDeptService.batchDel(ids);
	}
}
